$(function () {
    var tbody=window.document.getElementById("tbody-result");
    $.ajax({
        type:'GET',
        dataType:'json',
        url:contextPath+"",
        success:function (data) {
            // console.log(data.count);
            // console.log(data);
            var str="";
            // var l=data.message.length();
            // console.log(l);
            for (var i=0;i<data.count;i++) {
                // console.log(data.list[i].course_name);
                str += "<tr>" +
                    "<td>" + i + "</td>" +
                    "<td>" + data.list[i].course_name+"</td>"+
                    "<td>" + data.list[i].course_dir+ "</td>" +
                    "<td>" + data.list[i].finish + "</td>" +
                    "<td><button onclick='del(this)'>删除</button></td>" +
                    "</tr>";
            }
            console.log(str);
            tbody.innerHTML=str;
        }
        ,
        error:function () {
            alert("查询失败")
        }
    })
});

function  del(r) {
    var i=r.parentNode.parentNode.rowIndex-1;
    document.getElementById("tbody-result").deleteRow(i);
}